interface ValueLabelMapper {
    value: number | string;
    label: string;
}

export const activeList = () => {
    return [
        {
            label:'激活状态',
            value:1,
        },
        {
            label:'未激活状态',
            value:2
        }
    ] as ValueLabelMapper[]
}

export const stopList = () => {
    return [
        {
            label:'继续',
            value:1,
        },
        {
            label:'终止',
            value:2
        }
    ] as ValueLabelMapper[]
}

export const goodsList = () => {
    return [
        {
            label:'全部宝贝',
            value:"1",
        },
        {
            label:'全部宝贝2',
            value:"2",
        },
        {
            label:'全部宝贝3',
            value:"3",
        },
        
    ] as ValueLabelMapper[]
}

type ListFunction = () => ValueLabelMapper[];

export const value2label = (
    value: number | string, 
    defaultLabel: string, 
    listFunc: ListFunction
): string => {
    const list = listFunc();
    const idx = list.findIndex((item: ValueLabelMapper) => item.value === value);
    return idx === -1 ? defaultLabel : list[idx].label;
};